找传奇、传世资源到传世资源站!

socket连接程序源码

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

通过tcp连接的软件源码
from clipboard
public class MainActivity extends Activity implements OnClickListener {

private Button bnConnect;
private TextView txReceive;
private EditText edIP, edPort, edData;

private Handler handler = new Handler(Looper.getMainLooper());

private TcpClient client = new TcpClient() {

@Override
public void onConnect(SocketTransceiver transceiver) {
refreshUI(true);
}

@Override
public void onDisconnect(SocketTransceiver transceiver) {
refreshUI(false);
}

@Override
public void onConnectFailed() {
handler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "连接失败",
Toast.LENGTH_SHORT).show();
}
});
}

@Override
public void onReceive(SocketTransceiver transceiver, final String s) {
handler.post(new Runnable() {
@Override
public void run() {
txReceive.append(s);
}
});
}
};

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复